package com.qunar.train.mock.network;

import java.io.ByteArrayOutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.util.HashMap;
import java.util.Map;

/**
 * @author: xudong.tai
 * @since: 2018/8/14 Description:
 **/
public class MockHttpServletResponse implements javax.servlet.http.HttpServletResponse {

    private java.lang.String getContentTypeReturnValue = null;
    private java.lang.String getCharacterEncodingReturnValue = null;
    private java.lang.String encodeRedirectUrlReturnValue = null;
    private java.util.Locale getLocaleReturnValue = null;
    private javax.servlet.ServletOutputStream getOutputStreamReturnValue = null;
    private java.lang.String encodeUrlReturnValue = null;
    private int getBufferSizeReturnValue = 0;
    private boolean isCommittedReturnValue = false;
    private java.lang.String encodeURLReturnValue = null;
    private java.lang.String encodeRedirectURLReturnValue = null;
    private Map<String, String> header = new HashMap<>();
    private Map<String, Long> dataHeader = new HashMap<>();
    private Map<String, Integer> intHeader = new HashMap<>();

    private final ByteArrayOutputStream content = new ByteArrayOutputStream(1024);


    public java.lang.String getContentType() {
        return this.getContentTypeReturnValue;
    }

    public void sendError(int arg0) {
    }

    public void setCharacterEncoding(java.lang.String arg0) {
        this.getCharacterEncodingReturnValue = arg0;
    }

    public boolean containsHeader(java.lang.String arg0) {
        if (this.header.containsKey(arg0) || this.dataHeader.containsKey(arg0)
                || this.intHeader.containsKey(arg0)) {
            return true;
        } else {
            return false;
        }
    }

    public java.lang.String getCharacterEncoding() {
        return this.getCharacterEncodingReturnValue;
    }

    public void setDateHeader(java.lang.String arg0, long arg1) {
        this.dataHeader.put(arg0, arg1);
    }

    public void flushBuffer() {
    }

    public java.lang.String encodeRedirectUrl(java.lang.String arg0) {
        return this.encodeRedirectUrlReturnValue;
    }

    public void setIntHeader(java.lang.String arg0, int arg1) {
        this.intHeader.put(arg0, arg1);
    }

    public void setStatus(int arg0) {
    }

    public void sendError(int arg0, java.lang.String arg1) {
    }

    public java.util.Locale getLocale() {
        return this.getLocaleReturnValue;
    }

    public void sendRedirect(java.lang.String arg0) {
    }

    public void addHeader(java.lang.String arg0, java.lang.String arg1) {
        this.header.put(arg0, arg1);
    }

    public PrintWriter getWriter() throws UnsupportedEncodingException {
        Writer targetWriter = new OutputStreamWriter(this.content);
        return new PrintWriter(targetWriter);
    }

    public void setContentLength(int arg0) {
    }

    public javax.servlet.ServletOutputStream getOutputStream() {
        return this.getOutputStreamReturnValue;
    }

    public void addCookie(javax.servlet.http.Cookie arg0) {
    }

    public java.lang.String encodeUrl(java.lang.String arg0) {
        return this.encodeUrlReturnValue;
    }

    public int getBufferSize() {
        return this.getBufferSizeReturnValue;
    }

    public void setHeader(java.lang.String arg0, java.lang.String arg1) {
        this.header.put(arg0, arg1);
    }

    public void setBufferSize(int arg0) {
        this.getBufferSizeReturnValue = arg0;
    }

    public boolean isCommitted() {
        return this.isCommittedReturnValue;
    }

    public void addIntHeader(java.lang.String arg0, int arg1) {
        this.intHeader.put(arg0, arg1);
    }

    public void addDateHeader(java.lang.String arg0, long arg1) {
        this.dataHeader.put(arg0, arg1);
    }

    public void setStatus(int arg0, java.lang.String arg1) {
    }

    public void setContentType(java.lang.String arg0) {
        this.getContentTypeReturnValue = arg0;
    }

    public void resetBuffer() {
    }

    public void reset() {
    }

    public void setLocale(java.util.Locale arg0) {
        this.getLocaleReturnValue = arg0;
    }

    public java.lang.String encodeURL(java.lang.String arg0) {
        return this.encodeURLReturnValue;
    }

    public java.lang.String encodeRedirectURL(java.lang.String arg0) {
        return this.encodeRedirectURLReturnValue;
    }

    public void setEncodeRedirectUrl(java.lang.String p) {
        this.encodeRedirectUrlReturnValue = p;
    }

    public void setOutputStream(javax.servlet.ServletOutputStream p) {
        this.getOutputStreamReturnValue = p;
    }

    public void setEncodeUrl(java.lang.String p) {
        this.encodeUrlReturnValue = p;
    }


    public void setIsCommitted(boolean p) {
        this.isCommittedReturnValue = p;
    }

    public void setEncodeURL(java.lang.String p) {
        this.encodeURLReturnValue = p;
    }

    public void setEncodeRedirectURL(java.lang.String p) {
        this.encodeRedirectURLReturnValue = p;
    }


    public void clear() {
        this.getContentTypeReturnValue = null;
        this.getCharacterEncodingReturnValue = null;
        this.encodeRedirectUrlReturnValue = null;
        this.getLocaleReturnValue = null;
        this.getOutputStreamReturnValue = null;
        this.encodeUrlReturnValue = null;
        this.getBufferSizeReturnValue = 0;
        this.isCommittedReturnValue = false;
        this.encodeURLReturnValue = null;
        this.encodeRedirectURLReturnValue = null;
    }


}
